SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- update column delCount of table m_dictionaries
IF ( OBJECT_ID('dbo.update_dictionaries_delcount') IS NOT NULL ) 
   DROP PROCEDURE dbo.update_dictionaries_delcount
GO

CREATE PROCEDURE [dbo].[update_dictionaries_delcount] 
	@m_id int,
	@m_delCount int 
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[m_dictionaries]
	SET m_delCount = @m_delCount
	WHERE m_id = @m_id
END
GO

-- update role m_managerindict table

IF ( OBJECT_ID('dbo.update_managerindict_role') IS NOT NULL ) 
   DROP PROCEDURE dbo.update_managerindict_role
GO

CREATE PROCEDURE [dbo].[update_managerindict_role] 
	@m_userID int,
	@m_dictID int 
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[m_managerindict]
	SET m_role = 3 - m_role
	WHERE m_dictID = @m_dictID AND m_userID = @m_userID
END
GO

-- update date on table m_users
IF ( OBJECT_ID('dbo.update_users_date') IS NOT NULL ) 
   DROP PROCEDURE dbo.update_users_date
GO

CREATE PROCEDURE [dbo].[update_users_date] 
	@m_id int
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[m_users]
	SET m_date = GETDATE()
	WHERE m_id = @m_id
END
GO

-- update user password

IF ( OBJECT_ID('dbo.update_users_password') IS NOT NULL ) 
   DROP PROCEDURE dbo.update_users_password
GO

CREATE PROCEDURE [dbo].[update_users_password] 
	@m_username varchar(50),
	@m_password varchar(50),
	@m_newpass varchar(50)
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[m_users]
	SET m_password = @m_newpass
	WHERE m_username = @m_username AND m_password = @m_password
END
GO

-- Update Word

IF ( OBJECT_ID('dbo.update_word_status') IS NOT NULL ) 
   DROP PROCEDURE dbo.update_word_status
GO

CREATE PROCEDURE [dbo].[update_word_status] 
	@m_id int,
	@m_status int
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[m_word]
	SET m_status = @m_status
	WHERE m_id = @m_id
END

-- Update word meaning

IF ( OBJECT_ID('dbo.update_word_meaning') IS NOT NULL ) 
   DROP PROCEDURE dbo.update_word_meaning
GO

CREATE PROCEDURE [dbo].[update_word_meaning] 
	@m_id int,
	@m_meaning text
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[m_word]
	SET m_meaning = @m_meaning
	WHERE m_id = @m_id
END
GO